package com.ruoyi.project.gxgw_modules.messageList.controller;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.gxgw_modules.messageList.domain.MessageListVO;
import com.ruoyi.project.gxgw_modules.messageList.service.IMessageListService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * 会员消息管理 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-01-21
 */
@Controller
@RequestMapping("/gxgw_modules/messageList")
public class MessageListController extends BaseController
{
    private String prefix = "gxgw_modules/messageList";
	
	@Autowired
	private IMessageListService messageListService;
	
	@RequiresPermissions("gxgw_modules:messageList:view")
	@GetMapping()
	public String messageList()
	{
	    return prefix + "/messageList";
	}
	
	/**
	 * 查询会员消息管理列表
	 */
	@RequiresPermissions("gxgw_modules:messageList:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(MessageListVO messageList)
	{
		startPage();
        List<MessageListVO> list = messageListService.selectMessageListList(messageList);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出会员消息管理列表
	 */
	@RequiresPermissions("gxgw_modules:messageList:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(MessageListVO messageList)
    {
    	List<MessageListVO> list = messageListService.selectMessageListList(messageList);
        ExcelUtil<MessageListVO> util = new ExcelUtil<>(MessageListVO.class);
        return util.exportExcel(list, "messageList");
    }
	
	/**
	 * 新增会员消息管理
	 *//*
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	*//**
	 * 新增保存会员消息管理
	 *//*
	@RequiresPermissions("gxgw_modules:messageList:add")
	@Log(title = "会员消息管理", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(MessageList messageList)
	{		
		return toAjax(messageListService.insertMessageList(messageList));
	}

	*//**
	 * 修改会员消息管理
	 *//*
	@GetMapping("/edit/{mesListId}")
	public String edit(@PathVariable("mesListId") Integer mesListId, ModelMap mmap)
	{
		MessageList messageList = messageListService.selectMessageListById(mesListId);
		mmap.put("messageList", messageList);
	    return prefix + "/edit";
	}
	
	*//**
	 * 修改保存会员消息管理
	 *//*
	@RequiresPermissions("gxgw_modules:messageList:edit")
	@Log(title = "会员消息管理", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(MessageList messageList)
	{		
		return toAjax(messageListService.updateMessageList(messageList));
	}*/
	
	/**
	 * 删除会员消息管理
	 */
	@RequiresPermissions("gxgw_modules:messageList:remove")
	@Log(title = "会员消息管理", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(messageListService.deleteMessageListByIds(ids));
	}
	
}
